<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page  import="user.com.*" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'jingji.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<style type="text/css">
body{background-image:url(C:\Users\asus\Desktop\新建文件夹\2.jpg);}
table
{
border-collapse:collapse;
}
taber,td,tr
{
border:1px solid blue;
}
</style>
  </head>
  <%! int pageSize=4; int pageCount; int showPage; %>
  <body>
    <%
List<Map<String,Object>> list=new ArrayList<Map<String,Object>>();
Map<String,Object> map1=new HashMap<String,Object>();
String sql="jingji";
myjdbc my3=new myjdbc();
list=my3.fenye(sql);
int i=my3.select2("jingji");
if(i%10==0){
	pageCount=i/10;
}else{
	pageCount=i/10+1;
}

String integer=request.getParameter("showPage");
if(integer==null){
integer="1";
}
try{showPage=Integer.parseInt(integer);
}catch(NumberFormatException e){
showPage=1;
}
if(showPage<=1){
showPage=1;
}
if(showPage>=pageCount){
showPage=pageCount;
}
%>
<table>
<tr><td>序号</td><td>书名</td><td>作者</td><td>售价</td><td>出版日期</td></tr>
<% 
for(int j=(showPage-1)*10;(showPage-1)*10<=j&&j<=showPage*10-1;j++){
	map1=list.get(j);
%>
<tr> 
<td><%=map1.get("id")%></td>
<td><%=map1.get("name") %></td>
<td><%=map1.get("zuozhe") %></td>
<td><%=map1.get("price") %></td>
<td><%=map1.get("riqi") %></td>
</tr>
<%
}
%>
</table>
<br>
第<%=showPage %>页 共<%=pageCount %>页
<br>
<a href="jingji.jsp?showPage=1">首页</a>
<a href="jingji.jsp?showPage=<%=showPage-1%>">上一页</a>
<%
for(int k=1;k<=pageCount;k++){
%>
<a href="jingji.jsp?showPage=<%=k%>"><%=k%></a>
<%}
%>
<a href="jingji.jsp?showPage=<%=showPage+1%>">下一页</a>
<a href="jingji.jsp?showPage=<%=pageCount%>">末页</a>
<form action="" method="get">
  跳转到第<input type="text" name="showPage" size="4">页
  <input type="submit" name="submit" value="跳转">
 </form>    
  </body>
</html>
